import json
from datetime import datetime, date, time
from typing import Any


class JSONEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, (datetime, date, time)):
            return obj.isoformat()
        return super().default(obj)


def json_marshal(data: Any, indent: int = None, **kwargs) -> str:
    return json.dumps(data, cls=JSONEncoder, ensure_ascii=False, indent=indent, **kwargs)


def json_unmarshal(data: Any):
    return json.loads(data)
